package com.luoke.handler;

import com.luoke.constant.SubmoduleTypeConstant;
import com.luoke.result.Result;
import com.luoke.service.BattleResponseService;
import com.luoke.service.impl.BattleResponseServiceImpl;
import org.java_websocket.WebSocket;

/**
 * 战斗响应分发处理层
 */
public class BattleResponseHandler {

    private BattleResponseService battleResponseService = new BattleResponseServiceImpl();

    public void handler(WebSocket conn, Result result) {
        if (result.getCommand().equals(SubmoduleTypeConstant.SHOW_USER_WAIT_ONLINE_NAME)) { //处理客户端给的显示在线玩家的请求
            battleResponseService.showUserOnlineName(conn, result);
        } else if (result.getCommand().equals(SubmoduleTypeConstant.SHOW_WAIT_FOR_USER)) {//处理客户端给的显示等待玩家的请求
            battleResponseService.showWaitForUser(conn, result);
        } else if (result.getCommand().equals(SubmoduleTypeConstant.INITIATE_BATTLE_REQUEST)) { //处理对战请求
            battleResponseService.battleRequest(conn, result);
        } else if (result.getCommand().equals(SubmoduleTypeConstant.ACCEPT_BATTLE_INVITATION)) {//处理客户端接受或拒绝战斗邀请的请求
            battleResponseService.acceptBattleRequest(conn, result);
        } else if (result.getCommand().equals(SubmoduleTypeConstant.WAIT_FOR_USER)) { //处理客户端加入等待区的请求
            battleResponseService.waitForUser(conn, result);
        } else if (result.getCommand().equals(SubmoduleTypeConstant.MATCH_BATTLE)) {//处理客户端从匹配入口进入的请求
            battleResponseService.matchBattle(conn, result);
        }else if (result.getCommand().equals(SubmoduleTypeConstant.BATTLE_QUIT)){
            battleResponseService.battleQuit(conn,result);
        } else if (result.getCommand().equals(SubmoduleTypeConstant.EXPERIENCE)) {
            battleResponseService.upLevel(conn,result);
        }

    }
}
